<template>
    <div class="template-form-Lu">
        <a-modal
            title=""
            :visible="applicationFormVisible"
            :maskClosable="false"
            :closable="true"
            :destroyOnClose="true"
            width="100%"
            :dialog-style="{ margin: '0 auto' }"
            wrapClassName="form-modal-Lu"
            @cancel="closeVisible">
            <template slot="footer">
                <div v-if="linkName == '科室审核'">
                    <a-button @click="closeVisible">关闭</a-button>
                    <a-button class="blue-btn" @click="saveTable('提交')">中心分管领导审核</a-button>
                    <a-button class="blue-btn" @click="jobFg">中心分管领导审批</a-button>
                    <a-button class="blue-btn" @click="jobZyld">直达中心主要领导审批</a-button>
                    <a-button class="red-btn" @click="returnClick">退回</a-button>
                </div>
                <div v-else>
                    <a-button v-if="showFooter == false" key="back" @click="saveTable('保存')">
                        保存
                    </a-button>
                    <a-button :loading="loading" v-if="showFooter == false" class="blue-btn" @click="subTable('提交')">
                        提交
                    </a-button>
                    <a-button v-if="showFooter" @click="closeVisible" type="primary">关闭</a-button>
                    <a-button v-if="linkName == '数据修订'" @click="editForm" class="blue-btn">确认修订</a-button>
                    <a-button v-if="linkName !== '起草' && linkName !=='我的已办'" @click="returnClick" class="red-btn">退回</a-button>
                </div>
            </template>
            <a-tabs type="card" v-if="applicationFormVisible" @change="callback">
                <a-tab-pane key="1" tab="申请事项审批表">

                    <div id="printTest" class="print-div-shu red-table">
                        <a-form-model
                            ref="ruleForm"
                            :model="form"
                            :rules="rules"
                        >
                            <h1 class="h1-page">xx壮族自治区食品药品审评查验中心<br/>申请事项审批表</h1>
                            <table border="1" cellspacing="0" class="table-Lu xzswsp-table">
                                <tr>
                                    <th>时间</th>
                                    <td v-if="linkName == '起草'">
                                        <a-form-model-item ref="frq" prop="frq">
                                            <a-date-picker
                                                style="width: 60%"
                                                v-model="form.frq"
                                                @change="dateChange"/>
                                        </a-form-model-item>
                                    </td>
                                    <td v-else>
                                        {{ form.frq }}
                                    </td>
                                    <th>自然编号</th>
                                    <td v-if="linkName == '起草'">
                                        <a-form-model-item ref="fzrbh" prop="fzrbh">
                                            <a-input v-model="form.fzrbh" placeholder="请输入自然编号:" type="textarea" />
                                        </a-form-model-item>
                                    </td>
                                    <td v-else>
                                        {{ form.fzrbh }}
                                    </td>
                                </tr>
                                <tr>
                                    <th>科室</th>
                                    <td>
                                        {{ form.fks?form.fks:getKs() }}
                                    </td>
                                    <th>类别</th>
                                    <td v-if="linkName == '起草'">
                                        <a-form-model-item ref="flb" prop="flb">
                                            <compSelector
                                                v-model="form.flb"
                                                :defaultValue="form.flb"
                                                :compType="typeSelect"
                                                @selectHandleChange="flbChange"
                                                placeholder="请选择行政事务审批类别"
                                                dictionaryType="OA行政事务审批类别"
                                                class="oaApply-compSelector"/>
                                        </a-form-model-item>
                                    </td>
                                    <td v-else>
                                        {{ form.flb }}
                                    </td>
                                </tr>
                                <tr>
                                    <th>事项名称</th>
                                    <td v-if="linkName == '起草'" colspan="3">
                                        <a-form-model-item ref="fsx" prop="fsx">
                                            <a-textarea v-model="form.fsx" placeholder="请输入事项名称:" :auto-size="{ minRows: 1}"/>
                                        </a-form-model-item>
                                    </td>
                                    <td v-else colspan="3">
                                        {{ form.fsx }}
                                    </td>
                                </tr>
                                <tr>
                                    <th>具体内容</th>
                                    <td v-if="linkName == '起草'" colspan="3">
                                        <a-form-model-item ref="fnbyj" prop="fnbyj">
                                            <a-textarea v-model="form.fnbyj" placeholder="请输入具体内容:" :auto-size="{ minRows: 2}"/>
                                        </a-form-model-item>
                                    </td>
                                    <td v-else colspan="3">
                                        <div>
                                            <p class="text-align-left">{{ form.fnbyj }}</p>
                                            <div class="yjqm-right-bottom">
                                                经办人：<span class="yjqmImg">{{ form.fnbr }}</span>
                                                <span>{{ form.fnbsj }}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr v-if="linkName == '起草' || linkName == '数据修订'">
                                    <th>附件</th>
                                    <td colspan="3">
                                        <div>
                                            <a-form layout="inline" style="display: flex;justify-content: flex-start;">
                                                <a-form-item class="vxe-table-box-w" >
                                                    <a-upload style="display: inline-block;" :beforeUpload="beforeUpload" action="" @change="uploadClick">
                                                        <a-button class="blue-btn">上传附件</a-button>
                                                    </a-upload>
                                                </a-form-item>
                                            </a-form>
                                            <a-list item-layout="horizontal" :data-source="filesListData">
                                                <a-list-item slot="renderItem" slot-scope="item, index">
                                                    <a-list-item-meta>
                                                        <a @click="openFiles(item)" slot="title" href="#">{{ item.fmc }}</a>
                                                    </a-list-item-meta>
                                                    <a-button style="margin-right: 10px;" class="blue-btn" @click="openFiles(item)" >预览</a-button>
                                                    <a-button style="margin-right: 10px;" class="blue-btn" @click="downloadFiles(item)" >下载附件</a-button>
                                                    <a-button
                                                        class="red-btn"
                                                        style="margin-right: 10px;"
                                                        @click="deleteFiles(item.id)" >
                                                        删除附件
                                                    </a-button>
                                                </a-list-item>
                                            </a-list>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <th>主办科室意见</th>
                                    <td v-if="linkName == '科室审核' || linkName == '数据修订'" colspan="3">
                                        <a-form-model-item ref="fksldyj" prop="fksldyj">
                                            <reviewOpinions
                                              ref="reviewOpinionsRefKs"
                                              @getInputOpinion="getInputOpinion"
                                              @openOpinions="ksOpinions"
                                               v-decorator="[
                                                'fksldyj', {initialValue:form.fksldyj,rules: rules.fksldyj}]"/>
                                        </a-form-model-item>
                                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                                            <a-input
                                                v-model="form.fksldyjr"
                                                @click="checkMan('fksldyjr',form.fksldyjr)"
                                                placeholder=""
                                                class="checkMan-Xiu">
                                            </a-input>
                                            <a-date-picker
                                                show-time
                                                placeholder=""
                                                v-model="form.fksldyjsj"
                                                @change="timeChang($event,'fksldyjsj')"
                                                class="checkTime-Xiu"
                                                />
                                        </div>
                                    </td>
                                    <td v-else colspan="3">
                                        <div>
                                            <p class="text-align-left">{{ form.fksldyj }}</p>
                                            <div class="yjqm-right-bottom">
                                                <img v-if="getUrl('科室审核') && form.fksldyjsj" :src="getUrl('科室审核')" class="yjqmImg"/>
                                                <span v-else class="yjqmImg">{{ form.fksldyjr }}</span>
                                                <span>{{ form.fksldyjsj }}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <!-- <tr>
                                    <th>办公室意见</th>
                                    <td v-if="linkName == '办公室意见' || linkName == '数据修订'" colspan="3">
                                        <a-form-model-item ref="fbgsyj" prop="fbgsyj">
                                            <reviewOpinions
                                              ref="reviewOpinionsRefBgs"
                                              @getInputOpinion="getInputOpinion"
                                              @openOpinions="bgsOpinions"
                                              v-decorator="[
                                                  'fbgsyj', {initialValue:form.fbgsyj,rules: rules.fbgsyj}]"/>
                                        </a-form-model-item>
                                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                                            <a-input
                                                v-model="form.fbgsyjr"
                                                @click="checkMan('fbgsyjr',form.fbgsyjr)"
                                                placeholder=""
                                                class="checkMan-Xiu">
                                            </a-input>
                                            <a-date-picker
                                                show-time
                                                placeholder=""
                                                v-model="form.fbgsyjsj"
                                                @change="timeChang($event,'fbgsyjsj')"
                                                class="checkTime-Xiu"
                                                />
                                        </div>
                                    </td>
                                    <td v-else colspan="3">
                                        <div>
                                            <p class="text-align-left">{{ form.fbgsyj }}</p>
                                            <div class="yjqm-right-bottom">
                                                <img v-if="getUrl('办公室意见') && form.fbgsyjr" :src="getUrl('办公室意见')" class="yjqmImg"/>
                                                <span v-else class="yjqmImg">{{ form.fbgsyjr }}</span>
                                                <span>{{ form.fbgsyjsj }}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr> -->
                                <tr>
                                    <th>中心分管领导<br/>意见</th>
                                    <td v-if="linkName == '中心分管领导审核' || linkName == '数据修订'" colspan="3">
                                        <a-form-model-item ref="ffgldyj" prop="ffgldyj">
                                            <reviewOpinions
                                              ref="reviewOpinionsRefFg"
                                              @getInputOpinion="getInputOpinion"
                                              @openOpinions="fgOpinions"
                                              v-decorator="[
                                                    'ffgldyj', {initialValue:form.ffgldyj,rules: rules.ffgldyj}]"/>
                                        </a-form-model-item>
                                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                                            <a-input
                                                v-model="form.ffgldyjr"
                                                @click="checkMan('ffgldyjr',form.ffgldyjr)"
                                                placeholder=""
                                                class="checkMan-Xiu">
                                            </a-input>
                                            <a-date-picker
                                                show-time
                                                placeholder=""
                                                v-model="form.ffgldyjsj"
                                                @change="timeChang($event,'ffgldyjsj')"
                                                class="checkTime-Xiu"
                                                />
                                        </div>
                                    </td>
                                    <td v-else colspan="3">
                                        <div>
                                            <p class="text-align-left">{{ form.ffgldyj }}</p>
                                            <div class="yjqm-right-bottom">
                                                <img v-if="getUrl('中心分管领导审核') && form.ffgldyjsj" :src="getUrl('中心分管领导审核')" class="yjqmImg"/>
                                                <span v-else class="yjqmImg">{{ form.ffgldyjr }}</span>
                                                <span>{{ form.ffgldyjsj }}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <th>中心主要领导<br/>批示</th>
                                    <td v-if="linkName == '中心主要领导审核' || linkName == '数据修订'" colspan="3">
                                        <a-form-model-item ref="fzxld" prop="fzxld">
                                            <reviewOpinions
                                              ref="reviewOpinionsRefZxld"
                                              @getInputOpinion="getInputOpinion"
                                              @openOpinions="zxldOpinions"
                                              v-decorator="[
                                                      'fzxld', {initialValue:form.fzxld,rules: rules.fzxld}]"/>
                                        </a-form-model-item>
                                        <div v-if="linkName == '数据修订'" class="yjqm-right-bottom">
                                            <a-input
                                                v-model="form.fzxldpsr"
                                                @click="checkMan('fzxldpsr',form.fzxldpsr)"
                                                placeholder=""
                                                class="checkMan-Xiu">
                                            </a-input>
                                            <a-date-picker
                                                show-time
                                                placeholder=""
                                                v-model="form.fzxldpssj"
                                                @change="timeChang($event,'fzxldpssj')"
                                                class="checkTime-Xiu"
                                                />
                                        </div>
                                    </td>
                                    <td v-else colspan="3">
                                        <div>
                                            <p class="text-align-left">{{ form.fzxld }}</p>
                                            <div class="yjqm-right-bottom">
                                                <img v-if="getUrl('中心主要领导审核') && form.fzxldpssj" :src="getUrl('中心主要领导审核')" class="yjqmImg"/>
                                                <span v-else class="yjqmImg">{{ form.fzxldpsr }}</span>
                                                <span>{{ form.fzxldpssj }}</span>
                                            </div>
                                        </div>
                                    </td>
                                </tr>
                                <tr>
                                    <th>备注</th>
                                    <td colspan="3">
                                        <a-input
                                            v-if="linkName == '中心主要领导审核' || linkName == '数据修订'"
                                            v-model="form.fbz"
                                            placeholder="备注:"
                                            type="textarea"
                                            />
                                        <p v-else class="text-align-left">{{ form.fbz }}</p>
                                    </td>
                                </tr>
                            </table>
                        </a-form-model>
                    </div>

                </a-tab-pane>
                <a-tab-pane v-if="linkName == '我的已办'" key="2" tab="流转记录">
                    <a-table
                        :columns="lzColumns"
                        :data-source="lzList"
                        bordered
                        style="border-color: #d9d9d9;font-weight: 600;text-align: center;"
                        :customRow="customRow">
                    </a-table>
                </a-tab-pane>
                <a-tab-pane v-if="linkName !== '起草' && linkName !== '数据修订'" key="3" tab="表单附件">
                    <a-table
                        :columns="fjColumns"
                        :data-source="filesListData"
                        bordered
                        style="border-color: #d9d9d9;font-weight: 600;text-align: center;"
                        :customRow="customRow">
                        <span slot="operation_btn" slot-scope="text, record">
                        <a-button class="blue-btn" @click="openFiles(record)" style="margin-right: 10px;">查看</a-button>
                        <a-button class="blue-btn" @click="downloadFiles(record)">下载</a-button>
                        </span>
                    </a-table>
                </a-tab-pane>
                <a-button
                    v-if="showPrintBtn(linkName,form.flczt,tabsKey)"
                    slot="tabBarExtraContent"
                    v-print="printObj"
                    class="print-btn">
                    打印
                </a-button>
            </a-tabs>
        </a-modal>
        <personnelList ref="personnelListRef" :modaObj="modaObj" @checkPersonnel="checkPersonnel"></personnelList>
    </div>
</template>
<script>
import {initBzFlow,saveFlow,submitFlow,flowJkPage,downMyQm,edit,
        fjupload,fjedit,openFile,downLoadOa,fjlist,deleleMinioFile,
        queryAllYbJob,returnUpperzdyFlowJob,queryJobByJobId,fjAdd} from './service/index'
import compSelector from '@/components/compSelector/compSelector'
import {typeSelect,} from '@/components/compSearchCriteria/ContractType'
import personnelList from '../../modal/personnelList.vue'
import blobType from '@/common/blobType'
import store from '@/store'
import YchConstant from '@/api/YchConstant'
import moment from 'moment'
export default {
    props:{
        formData:{
            type:[Array,Object],
            default: () => {},
            required:false
        },
        linkName:{
            type:String,
            default:'',
            required:false,
        },
    },
    components:{
        compSelector,
        personnelList
    },
    data() {
        return {
            moment:moment,
            loading: false,
            cform:this.$form.createForm(this, { name: 'cform' }),
            rules:{
                frq: [{
                required: true,
                message: '请选择时间',
                trigger: 'change',
                }],
                fzrbh: [{
                required: true,
                message: '请输入自然编号',
                trigger: 'blur',
                }],
                flb: [{
                required: true,
                message: '请选择类别',
                trigger: 'change',
                }],
                fsx: [{
                required: true,
                message: '请输入事项名称',
                trigger: 'blur',
                }],
                flb: [{
                required: true,
                message: '请选择行政事务审批类别',
                trigger: 'blur',
                }],
                fnbyj: [{
                required: true,
                message: '请输入具体内容',
                trigger: 'blur',
                }],
                fksldyj: [{
                required: true,
                message: '请输入科室领导意见',
                trigger: 'blur',
                }],
                fbgsyj: [{
                required: true,
                message: '请输入办公室意见',
                trigger: 'blur',
                }],
                ffgldyj: [{
                required: true,
                message: '请输入中心分管领导意见',
                trigger: 'blur',
                }],
                fzxld: [{
                required: true,
                message: '请输入中心主要领导意见',
                trigger: 'blur',
                }],
            },
            typeSelect:typeSelect,
            applicationFormVisible: false,
            form: {
                id: "",
                fbgsyj: "",
                fbgsyjr: "",
                fbgsyjsj: "",
                fbz: "",
                fks: "",
                fksldyj: "",
                fksldyjr: "",
                fksldyjsj: "",
                flb: "",
                flczt: "",
                fnbr: "",
                fnbsj: "",
                fnbyj: "",
                frq: "",
                fsffqlc: "",
                fsx: "",
                fuserid: "",
                fzrbh: "",
                fzxld: "",
                fzxldpsr: "",
                fzxldpssj: "",
                ffgldyj: '',
                ffgldyjr: '',
                ffgldyjsj: '',
                fdbrid: '',
                fdbr: '',
                fsftgdwld: '',
            },
            kongForm: {},
            lzColumns: [
                {
                title: '环节名称',
                dataIndex: 'fhjmc',
                key: 'fhjmc',
                width: 150,
                },{
                title: '待办人',
                dataIndex: 'fdbr',
                key: 'fdbr',
                width: 100,
                },{
                title: '办理人',
                dataIndex: 'fblr',
                key: 'fblr',
                width: 100,
                },{
                title: '发送时间',
                dataIndex: 'ffssj',
                key: 'ffssj',
                width: 170,
                },{
                title: '办理时间',
                dataIndex: 'fblsj',
                key: 'fblsj',
                width: 170,
                },{
                title: '办理状态',
                dataIndex: 'fblzt',
                key: 'fblzt',
                width: 100,
                },{
                title: '办理类型',
                dataIndex: 'fbllx',
                key: 'fbllx',
                width: 300,
                },{
                title: '办理意见',
                dataIndex: 'fblyj',
                key: 'fblyj',
                },
            ],
            lzList: [],
            showFooter: false,
            compSelectorkey:null,
            imgList: [
                {fhjmc:'科室审核',url: ''},
                {fhjmc:'办公室意见',url: ''},
                {fhjmc:'中心分管领导审核',url:''},
                {fhjmc:'中心主要领导审核',url: ''},
            ],
            tabsKey: '1',
            printObj:{
                id:"printTest", //需要打印的id名称
                popTitle:"宣传信息审批表",//文档的名称
                // preview:true,//预览功能，不好用
                zIndex:'20002',
                beforeOpenCallback(vue){
                    // //console.log('打印回调',vue)
                },
                openCallback (vue) {//打开之前
                    // //console.log('打开之前',vue)
                },
                closeCallback (vue) {//关闭了打印工具
                    // //console.log('关闭了打印工具')
                },
            },
            fjColumns: [
                {
                title: '文件名',
                dataIndex: 'fmc',
                key: 'fmc',
                align: 'center'
                },{
                title: '文件类型',
                dataIndex: 'fwjlx',
                key: 'fwjlx',
                align: 'center'
                },{
                title: '上传时间',
                dataIndex: 'fscsj',
                key: 'fscsj',
                align: 'center'
                },{
                title: '上传人',
                dataIndex: 'fscr',
                key: 'fscr',
                align: 'center'
                },{
                title: '操作',
                key: 'id',
                scopedSlots: { customRender: 'operation_btn' },
                },
            ],
            modaObj: {},
            filesListData: [],
            returnList: [],
            returmCheck: '',
            returnYj: '',
        }
    },
    mounted(){
        this.kongForm = JSON.parse(JSON.stringify(this.form))
    },
    methods: {
        showPrintBtn(linkName,flczt,tabsKey){
            if(linkName == '我的已办' && flczt == '流程结束' && tabsKey == '1'){
                return true
            } else {
                return false
            }
        },
        reviewRecordsFocusEvent(){},
        // 是否只读
        readOnly(type){
            if(this.linkName ==  type){
                return false
            } else {
                return true
            }
        },
        getKs(){
            // //console.log(store.getters.userInfo.orgName)
            return store.getters.userInfo.orgName
        },
        flbChange(val){
            this.cform.setFieldsValue({
                flb:val,
            });
        },
        dateChange(val){
            this.frq = moment(val).format('YYYY-MM-DD')
            //console.log(this.frq)
        },
        timeChang(val,name){
            let data = this.form
            data[name] = moment(val).format('YYYY-MM-DD HH:mm:ss')
        },
        customRow() {
        return {
            style: {
                'font-size' : '16px',
                'text-align' : 'center'
            },
        }
        },
        callback(key) {
        // //console.log(key);
            this.tabsKey = key
        },
        getUrl(ids){
        let url = ''
        this.imgList.forEach(item => {
            if(item.fhjmc == ids){
            url = item.url
            }
        })
        return url
        },
        // 打开意见弹窗
        ksOpinions(){
            this.$refs.reviewOpinionsRefKs.getData({opinionType:'ksIdeaType',oldVal:this.form.fksldyj,valueData:{hjmc:'fksldyj'}})
        },
        bgsOpinions(){
            this.$refs.reviewOpinionsRefBgs.getData({opinionType:'bgsIdeaType',oldVal:this.form.fbgsyj,valueData:{hjmc:'fbgsyj'}})
        },
        fgOpinions(){
            this.$refs.reviewOpinionsRefFg.getData({opinionType:'fgIdeaType',oldVal:this.form.ffgldyj,valueData:{hjmc:'ffgldyj'}})
        },
        zxldOpinions(){
            this.$refs.reviewOpinionsRefZxld.getData({opinionType:'zxldIdeaType',oldVal:this.form.fzxld,valueData:{hjmc:'fzxld'}})
        },
        // 意见弹窗
        getInputOpinion(val,valueData){
        // //console.log(val,valueData)
        let data = this.form
        data[valueData.hjmc] = val
        this.cform.setFieldsValue({
            fksldyj:this.form.fksldyj,
            fbgsyj: this.form.fbgsyj,
            ffgldyj: this.form.ffgldyj,
            fzxld: this.form.fzxld,
        });
        },
        // 右上角关闭后的回调
        closeVisible(e){
            this.$emit('success')
            this.applicationFormVisible = false
            this.form = JSON.parse(JSON.stringify(this.kongForm))
            this.filesListData = []
        },
        // time
        timeChange(val,formItemName){
        formItemName = moment(val).format('YYYY-MM-DD')
        },
        // 保存+提交
        saveTable(str){
          if(this.linkName == '起草'){
              if(this.form.id){
                  if(str == '保存'){
                      let data = {
                          // jobid: this.form.jobid,
                          id: this.form.id,
                          fks: this.form.fks,
                          frq: moment(this.form.frq).format('YYYY-MM-DD'),
                          fzrbh: this.form.fzrbh,
                          fsx: this.form.fsx,
                          flb: this.form.flb,
                          fnbr: this.form.fnbr,
                          fnbyj: this.form.fnbyj,
                          fnbsj: this.form.fnbsj,
                      }
                      initBzFlow(data).then(res => {
                          if(res.code == 200){
                              this.$message.success(res.message)
                              this.form = {
                                  ...res.result.oaMap,
                                  jobid: res.result.jobMap.id,
                              }
                              let nian = this.form.frq.substr(0,4)
                              let yue = this.form.frq.substr(5,2)
                              let ri = this.form.frq.substr(8,2)
                              let rq = nian + '-' + yue + '-' + ri
                              this.form.frq = moment(rq)
                              //console.log(this.form.frq)
                          } else {
                              this.$message.warning(res.message)
                          }
                      })
                  } else if(str == '提交') {
                      this.loading = true
                      if(this.form.jobid){
                          let data = {
                              jobid: this.form.jobid,
                              oaid: this.form.id,
                              map: {
                                  fks: this.form.fks,
                                  frq: moment(this.form.frq).format('YYYY-MM-DD'),
                                  fzrbh: this.form.fzrbh,
                                  fsx: this.form.fsx,
                                  flb: this.form.flb,
                                  fnbr: this.form.fnbr,
                                  fnbyj: this.form.fnbyj,
                                  fnbsj: this.form.fnbsj,
                              },
                              currentNode: "",
                              dbrid: "",
                              lcmbCode: "",
                              nextNode: "",
                              nextNodeId: "",
                              opinion: this.form.fnbyj,
                              smgflag: ""
                          }
                          submitFlow(data).then(res => {
                              if(res.code == 200){
                                  this.$message.success(res.message)
                                  this.closeVisible()
                              } else {
                                  this.$message.warning(res.message)
                              }
                                  this.loading = false
                          })
                      } else {
                          let data1 = {
                              id: this.form.id,
                              fks: this.form.fks,
                              frq: moment(this.form.frq).format('YYYY-MM-DD'),
                              fzrbh: this.form.fzrbh,
                              fsx: this.form.fsx,
                              flb: this.form.flb,
                              fnbr: this.form.fnbr,
                              fnbyj: this.form.fnbyj,
                              fnbsj: this.form.fnbsj,
                          }
                          initBzFlow(data1).then(res => {
                          if(res.code == 200){
                              this.form = {
                                  ...res.result.oaMap,
                                  jobid: res.result.jobMap.id
                              }
                              let data2 = {
                                  jobid: this.form.jobid,
                                  oaid: this.form.id,
                                  map: {
                                      fks: this.form.fks,
                                      frq: moment(this.form.frq).format('YYYY-MM-DD'),
                                      fzrbh: this.form.fzrbh,
                                      fsx: this.form.fsx,
                                      flb: this.form.flb,
                                      fnbr: this.form.fnbr,
                                      fnbyj: this.form.fnbyj,
                                      fnbsj: this.form.fnbsj,
                                  },
                                  currentNode: "",
                                  dbrid: "",
                                  lcmbCode: "",
                                  nextNode: "",
                                  nextNodeId: "",
                                  opinion: this.form.fnbyj,
                                  smgflag: ""
                              }
                              this.loading = true
                              submitFlow(data2).then(res => {
                                  if(res.code == 200){
                                      this.$message.success(res.message)
                                      this.closeVisible()
                                  } else {
                                      this.$message.warning(res.message)
                                  }
                                  this.loading = false
                              })
                          }
                      })
                      }
                  }
              } else {
              let data = {
                  id: this.form.id,
                  fks: this.form.fks,
                  frq: moment(this.form.frq).format('YYYY-MM-DD'),
                  fzrbh: this.form.fzrbh,
                  fsx: this.form.fsx,
                  flb: this.form.flb,
                  fnbr: this.form.fnbr,
                  fnbyj: this.form.fnbyj,
                  fnbsj: this.form.fnbsj,
              }
              if(str == '提交'){
                  data = {
                  ...data,
                  fsffqlc: '是',
                  }
                  this.loading = true
              }
              initBzFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  if(str == '提交'){
                      this.closeVisible()
                  } else {
                      this.form = {
                          ...res.result.oaMap,
                          jobid: res.result.jobMap.id
                      }
                      let nian = this.form.frq.substr(0,4)
                      let yue = this.form.frq.substr(5,2)
                      let ri = this.form.frq.substr(8,2)
                      let rq = nian + '-' + yue + '-' + ri
                      this.form.frq = moment(rq)
                      //console.log(this.form.frq)
                      // this.form.id = res.result.id//赋值
                  }
                  this.$emit('success')
                  } else {
                  this.$message.warning(res.message)
                  }
                  this.loading = false
              })
              }
          } else if(this.linkName == '科室审核'){
              let data = {
                  jobid: this.formData.jobid,
                  oaid: this.formData.oaid,
                  map: {
                      fksldyj: this.form.fksldyj,
                      fksldyjr: this.form.fksldyjr,
                      fksldyjsj: this.form.fksldyjsj,
                  },
                  opinion: this.form.fksldyj,
                  currentNode: "",
                  dbrid: "",
                  lcmbCode: "",
                  nextNode: "",
                  nextNodeId: "",
                  smgflag: ""
              }
              if(str == '提交'){
              data = {
                  ...data,
                  fsffqlc: '是',
              }

              submitFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  this.closeVisible()
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              } else {
              saveFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  this.$emit('success')
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              }
          } else if(this.linkName == '办公室意见'){
              let data = {
                  jobid: this.formData.jobid,
                  oaid: this.formData.oaid,
                  map: {
                      fbgsyj: this.form.fbgsyj,
                      fbgsyjr: this.form.fbgsyjr,
                      fbgsyjsj: this.form.fbgsyjsj,
                  },
                  opinion: this.form.fbgsyj,
                  currentNode: "",
                  dbrid: "",
                  lcmbCode: "",
                  nextNode: "",
                  nextNodeId: "",
                  smgflag: ""
              }
              if(str == '提交'){
              data = {
                  ...data,
                  fsffqlc: '是'
              }
              submitFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  this.closeVisible()
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              } else {
              saveFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              }
          } else if(this.linkName == '中心分管领导审核'){
              let data = {
                  jobid: this.formData.jobid,
                  oaid: this.formData.oaid,
                  map: {
                      ffgldyj: this.form.ffgldyj,
                      ffgldyjr: this.form.ffgldyjr,
                      ffgldyjsj: this.form.ffgldyjsj,
                  },
                  opinion: this.form.ffgldyj,
                  currentNode: "",
                  dbrid: "",
                  lcmbCode: "",
                  nextNode: "",
                  nextNodeId: "",
                  smgflag: ""
              }
              if(str == '提交'){
              data = {
                  ...data,
                  fsffqlc: '是'
              }
              submitFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  this.closeVisible()
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              } else {
              saveFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              }
          } else if(this.linkName == '中心主要领导审核'){
              let data = {
                  jobid: this.formData.jobid,
                  oaid: this.formData.oaid,
                  map: {
                      fzxld: this.form.fzxld,
                      fzxldpsr: this.form.fzxldpsr,
                      fzxldpssj: this.form.fzxldpssj,
                      fbz: this.form.fbz
                  },
                  opinion: this.form.fzxld,
                  currentNode: "",
                  dbrid: "",
                  lcmbCode: "",
                  nextNode: "",
                  nextNodeId: "",
                  smgflag: ""
              }
              if(str == '提交'){
              data = {
                  ...data,
                  fsffqlc: '是'
              }
              submitFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  this.closeVisible()
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              } else {
              saveFlow(data).then(res => {
                  if(res.code == 200){
                  this.$message.success(res.message)
                  } else {
                  this.$message.warning(res.message)
                  }
              })
              }
          }
        },
        subTable(str){
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    var that = this
                    that.$confirm({
                        title: '您确定要提交吗?',
                        onOk() {
                            // //console.log('***************',that.loading,'****************')
                            //console.log(that.form)
                            if(that.linkName == '起草'){
                                if(that.form.id){
                                    if(str == '保存'){
                                        let data = {
                                            // jobid: that.form.jobid,
                                            id: that.form.id,
                                            fks: that.form.fks,
                                            frq: moment(that.form.frq).format('YYYY-MM-DD'),
                                            fzrbh: that.form.fzrbh,
                                            fsx: that.form.fsx,
                                            flb: that.form.flb,
                                            fnbr: that.form.fnbr,
                                            fnbyj: that.form.fnbyj,
                                            fnbsj: that.form.fnbsj,
                                        }
                                        initBzFlow(data).then(res => {
                                            if(res.code == 200){
                                                that.$message.success(res.message)
                                                that.form = {
                                                    ...res.result.oaMap,
                                                    jobid: res.result.jobMap.id,
                                                }
                                                let nian = that.form.frq.substr(0,4)
                                                let yue = that.form.frq.substr(5,2)
                                                let ri = that.form.frq.substr(8,2)
                                                let rq = nian + '-' + yue + '-' + ri
                                                that.form.frq = moment(rq)
                                                //console.log(that.form.frq)
                                            } else {
                                                that.$message.warning(res.message)
                                            }
                                        })
                                    } else if(str == '提交') {
                                        that.loading = true
                                        if(that.form.jobid){
                                            let data = {
                                                jobid: that.form.jobid,
                                                oaid: that.form.id,
                                                map: {
                                                    fks: that.form.fks,
                                                    frq: moment(that.form.frq).format('YYYY-MM-DD'),
                                                    fzrbh: that.form.fzrbh,
                                                    fsx: that.form.fsx,
                                                    flb: that.form.flb,
                                                    fnbr: that.form.fnbr,
                                                    fnbyj: that.form.fnbyj,
                                                    fnbsj: that.form.fnbsj,
                                                },
                                                currentNode: "",
                                                dbrid: "",
                                                lcmbCode: "",
                                                nextNode: "",
                                                nextNodeId: "",
                                                opinion: that.form.fnbyj,
                                                smgflag: ""
                                            }
                                            submitFlow(data).then(res => {
                                                if(res.code == 200){
                                                    that.$message.success(res.message)
                                                    that.closeVisible()
                                                } else {
                                                    that.$message.warning(res.message)
                                                }
                                                    that.loading = false
                                            })
                                        } else {
                                            let data1 = {
                                                id: that.form.id,
                                                fks: that.form.fks,
                                                frq: moment(that.form.frq).format('YYYY-MM-DD'),
                                                fzrbh: that.form.fzrbh,
                                                fsx: that.form.fsx,
                                                flb: that.form.flb,
                                                fnbr: that.form.fnbr,
                                                fnbyj: that.form.fnbyj,
                                                fnbsj: that.form.fnbsj,
                                            }
                                            initBzFlow(data1).then(res => {
                                            if(res.code == 200){
                                                that.form = {
                                                    ...res.result.oaMap,
                                                    jobid: res.result.jobMap.id
                                                }
                                                let data2 = {
                                                    jobid: that.form.jobid,
                                                    oaid: that.form.id,
                                                    map: {
                                                        fks: that.form.fks,
                                                        frq: moment(that.form.frq).format('YYYY-MM-DD'),
                                                        fzrbh: that.form.fzrbh,
                                                        fsx: that.form.fsx,
                                                        flb: that.form.flb,
                                                        fnbr: that.form.fnbr,
                                                        fnbyj: that.form.fnbyj,
                                                        fnbsj: that.form.fnbsj,
                                                    },
                                                    currentNode: "",
                                                    dbrid: "",
                                                    lcmbCode: "",
                                                    nextNode: "",
                                                    nextNodeId: "",
                                                    opinion: that.form.fnbyj,
                                                    smgflag: ""
                                                }
                                                that.loading = true
                                                submitFlow(data2).then(res => {
                                                    if(res.code == 200){
                                                        that.$message.success(res.message)
                                                        that.closeVisible()
                                                    } else {
                                                        that.$message.warning(res.message)
                                                    }
                                                    that.loading = false
                                                })
                                            }
                                        })
                                        }
                                    }
                                } else {
                                let data = {
                                    id: that.form.id,
                                    fks: that.form.fks,
                                    frq: moment(that.form.frq).format('YYYY-MM-DD'),
                                    fzrbh: that.form.fzrbh,
                                    fsx: that.form.fsx,
                                    flb: that.form.flb,
                                    fnbr: that.form.fnbr,
                                    fnbyj: that.form.fnbyj,
                                    fnbsj: that.form.fnbsj,
                                }
                                if(str == '提交'){
                                    data = {
                                    ...data,
                                    fsffqlc: '是',
                                    }
                                    that.loading = true
                                }
                                initBzFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    if(str == '提交'){
                                        that.closeVisible()
                                    } else {
                                        that.form = {
                                            ...res.result.oaMap,
                                            jobid: res.result.jobMap.id
                                        }
                                        let nian = that.form.frq.substr(0,4)
                                        let yue = that.form.frq.substr(5,2)
                                        let ri = that.form.frq.substr(8,2)
                                        let rq = nian + '-' + yue + '-' + ri
                                        that.form.frq = moment(rq)
                                        //console.log(that.form.frq)
                                        // that.form.id = res.result.id//赋值
                                    }
                                    that.$emit('success')
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                    that.loading = false
                                })
                                }
                            } else if(that.linkName == '科室审核'){
                                let data = {
                                    jobid: that.formData.jobid,
                                    oaid: that.formData.oaid,
                                    map: {
                                        fksldyj: that.form.fksldyj,
                                        fksldyjr: that.form.fksldyjr,
                                        fksldyjsj: that.form.fksldyjsj,
                                    },
                                    opinion: that.form.fksldyj,
                                    currentNode: "",
                                    dbrid: "",
                                    lcmbCode: "",
                                    nextNode: "",
                                    nextNodeId: "",
                                    smgflag: ""
                                }
                                if(str == '提交'){
                                data = {
                                    ...data,
                                    fsffqlc: '是',
                                }

                                submitFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                } else {
                                saveFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.$emit('success')
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                }
                            } else if(that.linkName == '办公室意见'){
                                let data = {
                                    jobid: that.formData.jobid,
                                    oaid: that.formData.oaid,
                                    map: {
                                        fbgsyj: that.form.fbgsyj,
                                        fbgsyjr: that.form.fbgsyjr,
                                        fbgsyjsj: that.form.fbgsyjsj,
                                    },
                                    opinion: that.form.fbgsyj,
                                    currentNode: "",
                                    dbrid: "",
                                    lcmbCode: "",
                                    nextNode: "",
                                    nextNodeId: "",
                                    smgflag: ""
                                }
                                if(str == '提交'){
                                data = {
                                    ...data,
                                    fsffqlc: '是'
                                }
                                submitFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                } else {
                                saveFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                }
                            } else if(that.linkName == '中心分管领导审核'){
                                let data = {
                                    jobid: that.formData.jobid,
                                    oaid: that.formData.oaid,
                                    map: {
                                        ffgldyj: that.form.ffgldyj,
                                        ffgldyjr: that.form.ffgldyjr,
                                        ffgldyjsj: that.form.ffgldyjsj,
                                    },
                                    opinion: that.form.ffgldyj,
                                    currentNode: "",
                                    dbrid: "",
                                    lcmbCode: "",
                                    nextNode: "",
                                    nextNodeId: "",
                                    smgflag: ""
                                }
                                if(str == '提交'){
                                data = {
                                    ...data,
                                    fsffqlc: '是'
                                }
                                submitFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                } else {
                                saveFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                }
                            } else if(that.linkName == '中心主要领导审核'){
                                let data = {
                                    jobid: that.formData.jobid,
                                    oaid: that.formData.oaid,
                                    map: {
                                        fzxld: that.form.fzxld,
                                        fzxldpsr: that.form.fzxldpsr,
                                        fzxldpssj: that.form.fzxldpssj,
                                        fbz: that.form.fbz
                                    },
                                    opinion: that.form.fzxld,
                                    currentNode: "",
                                    dbrid: "",
                                    lcmbCode: "",
                                    nextNode: "",
                                    nextNodeId: "",
                                    smgflag: ""
                                }
                                if(str == '提交'){
                                data = {
                                    ...data,
                                    fsffqlc: '是'
                                }
                                submitFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    that.closeVisible()
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                } else {
                                saveFlow(data).then(res => {
                                    if(res.code == 200){
                                    that.$message.success(res.message)
                                    } else {
                                    that.$message.warning(res.message)
                                    }
                                })
                                }
                            }
                        },
                        onCancel() {},
                    });
                } else {
                    this.$message.warning('有未填的必填项')
                }
            })
        },
        // 跳过单位领导审批,结束流程
        jobTable(){
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    let data = {}
                        data = {
                            jobid: this.form.jobid,
                            oaid: this.form.id,
                            map: {
                                ffgldyj: this.form.ffgldyj,
                                ffgldyjr: this.form.ffgldyjr,
                                ffgldyjsj: this.form.ffgldyjsj,
                            },
                            opinion: this.form.ffgldyj,
                            fsftgdwld: '是',
                            currentNode: "",
                            dbrid: "",
                            lcmbCode: "",
                            nextNode: "",
                            nextNodeId: "",
                            smgflag: ""
                            // nextNode: '信息发布办理'
                        }

                        submitFlow(data).then(res => {
                            if(res.code == 200){
                            this.$message.success(res.message)
                            this.closeVisible()
                            } else {
                            this.$message.warning(res.message)
                            }
                        })
                }
            })
        },
        jobFg(){
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    let data = {
                        jobid: this.formData.jobid,
                        oaid: this.formData.oaid,
                        map: {
                            fbgsyj: this.form.fbgsyj,
                            fbgsyjr: this.form.fbgsyjr,
                            fbgsyjsj: this.form.fbgsyjsj,
                        },
                        opinion: this.form.fbgsyj,
                        fsftgdwld: '是',
                        currentNode: "",
                        dbrid: "",
                        lcmbCode: "",
                        nextNode: "",
                        nextNodeId: "",
                        smgflag: ""
                    }

                    submitFlow(data).then(res => {
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.closeVisible()
                        } else {
                            this.$message.warning(res.message)
                        }
                    })
                }
            })
        },
        jobZyld(){
            this.$refs.ruleForm.validate(valid => {
                if (valid) {
                    let data = {
                        jobid: this.formData.jobid,
                        oaid: this.formData.oaid,
                        map: {
                            fbgsyj: this.form.fbgsyj,
                            fbgsyjr: this.form.fbgsyjr,
                            fbgsyjsj: this.form.fbgsyjsj,
                        },
                        opinion: this.form.fbgsyj,
                        nextNode: '中心主要领导审核',
                        currentNode: "",
                        dbrid: "",
                        lcmbCode: "",
                        nextNodeId: "",
                        smgflag: ""
                    }

                    submitFlow(data).then(res => {
                        if(res.code == 200){
                            this.$message.success(res.message)
                            this.closeVisible()
                        } else {
                            this.$message.warning(res.message)
                        }
                    })
                }
            })
        },
        //
        checkMan(place,man){
        this.$nextTick(_ => {
            this.modaObj = {place: place,manList: man}
            this.$refs.personnelListRef.personnelListVisible = true
                })
        },
        // 选择人员
        checkPersonnel(place,id,name){
        this.$refs.personnelListRef.personnelListVisible = false
        // //console.log('-------------------')
        const data = this.form
        data[place] = name.toString()
        // data[fdbrid] = id.toString(),
        // data[fdbr] = name.toString()
        // let Data = {
        //     jobid: this.form.jobid,
        //     fdbrid: id.toString(),
        //     fdbr: name.toString()
        // }
        // zbFlows(Data).then(res => {
        //   //console.log(res)
        // })
        },
        // 数据修订
        editForm(){
        let data = {
            id: this.form.id,
            fbgsyj: this.form.fbgsyj,
            fbgsyjr: this.form.fbgsyjr,
            fbgsyjsj: this.form.fbgsyjsj,
            fbz: this.form.fbz,
            fks: this.form.fks,
            fksldyj: this.form.fksldyj,
            fksldyjr: this.form.fksldyjr,
            fksldyjsj: this.form.fksldyjsj,
            flb: this.form.flb,
            flczt: this.form.flczt,
            fnbr: this.form.fnbr,
            fnbsj: this.form.fnbsj,
            fnbyj: this.form.fnbyj,
            frq: moment(this.form.frq).format("YYYY年MM月DD日"),
            fsffqlc: this.form.fsffqlc,
            fsx: this.form.fsx,
            // fuserid: this.form.fuserid,
            fzrbh: this.form.fzrbh,
            fzxld: this.form.fzxld,
            fzxldpsr: this.form.fzxldpsr,
            fzxldpssj: this.form.fzxldpssj,
            fdbrid: this.form.fdbrid,
            fdbr: this.form.fdbr
        }
        edit(data).then(res => {
            //console.log(res)
            if(res.code == 200){
            this.$message.success(res.message)
            // this.closeVisible()
            } else {
            this.$message.warning(res.message)
            }
        })
        },
        // 退回
        getqueryAllYbJob(){
        queryAllYbJob({jobid:this.form.jobid}).then(res => {
            //console.log(res)
            this.returnList = res.result
        })
        },
        //
        returnChange(value){
        this.returmCheck = value
        },
        //
        returnBtn(){
        let data = {
            jobid: this.form.jobid,
            opinion: this.returnYj,
            shjid: this.returmCheck
        }
        returnUpperzdyFlowJob(data).then(res => {
            if(res.code == 200){
            this.$message.success(res.message)
            let jobid = this.form.jobid
            queryJobByJobId({jobid:jobid}).then(res => {
                //console.log(res)
                this.form = res.result.sqsx
            })
            } else {
            this.$message.warning(res.message)
            }
        })
        },
        // 附件
        beforeUpload(e){
        return false
        },
        // 上传附件
        async uploadClick({file}){
        //console.log(file)
        if(!this.form.id){
            let data = []
            data = {
            id: this.form.id,
            fks: this.form.fks,
            frq: this.form.frq,
            fzrbh: this.form.fzrbh,
            fsx: this.form.fsx,
            flb: this.form.flb,
            fnbr: this.form.fnbr,
            fnbyj: this.form.fnbyj,
            fnbsj: this.form.fnbsj,
            }
            const res = await fjAdd(data)
            this.form = res.result
            this.form.id = res.result.id
            if (res.success) {
            //console.log('888888')
            this.uploadClicka(file,this.form.id)
            }
        } else {
            //console.log('0000000000')
            this.uploadClicka(file,this.form.id)
        }
        },
        uploadClicka(file,id){
        //console.log(file)
        var that = this
            if(typeof file.uid !== 'undefined') {
            const fileData = new FormData();
            fileData.append("file",file);
            fileData.append("oaid",id);
            //console.log(fileData)
            fjupload(fileData).then(res => {
                //console.log('fileData',res)
                if (res.success) {
                that.$message.success(res.message)
                fjlist({foaid:id}).then(res => {
                    that.filesListData = []
                    that.filesListData = res.result.records
                })
                } else {
                that.$message.warning(res.message)
                }
            })
            }
        },
        // 预览
        openFiles(item){
            //console.log(item)
            if(item.fwjlx.indexOf('pdf') !== -1){
              //console.log()
              window.open(
                  bootConfig[process.env.NODE_ENV].locality_ApI2+YchConstant.SPZX_OA+'/oaFjzyk/downLoadOa?id='+item.id
              )
            } else {
              openFile({id:item.id}).then(res => {
                if(!res.success){
                      this.$message.warning('当前附件类型不支持预览,请下载查看')
                } else {
                    window.open(res.result.wordUrl, '_blank')
                }
              })
            }

        },
        // 下载附件
        downloadFiles(val){
        //console.log('下载',val)
        var that = this
        var fileName = val.fmc
        downLoadOa({id:val.id}).then((data) => {
            // //console.log(data)
            if (!data) {
                that.$message.warning('文件下载失败')
                return
            }
            let url = window.URL.createObjectURL(new Blob([data], { type: blobType.type[blobType.suffix.indexOf(val.fwjlx)] }))
            let link = document.createElement('a')
            link.style.display = 'none'
            link.href = url
            link.setAttribute('download', fileName)
            document.body.appendChild(link)
            link.click()
            document.body.removeChild(link) //下载完成移除元素
            window.URL.revokeObjectURL(url) //释放掉blob对象
            // this.vxModal.visabled = false;
        })
        },
        // 删除附件
        deleteFiles(idd){
            //console.log('idd',idd)
            var that = this
            that.$confirm({
              title: '您确定要删除这些申请吗?',
              content: '',
              okText: '确定',
              okType: 'danger',
              cancelText: '取消',
              onOk() {
                deleleMinioFile({id:idd}).then(res => {
                    if(res.code == 200){
                    that.$message.success('删除成功')
                    fjlist({foaid:that.form.id}).then(res => {
                        that.filesListData = []
                        that.filesListData = res.result.records
                    })
                    } else {
                    that.$message.warning(res.message)
                    }
                })
              },
              onCancel() {
                //console.log('Cancel');
              },
            });
        },
        // 退回意见
        returnClick(){
            this.$refs.ruleForm.validate(valid => {
                if (valid){
                    queryAllYbJob({jobid:this.form.jobid}).then(res => {
                        let list = res.result
                        list.forEach(item => {
                            if(item.fhjmc == '起草'){
                                this.returnFuntion(this.form.jobid,item.id)
                            }
                        })
                    })
                }
            })
        },
        returnFuntion(jobid,ids){
            let returnStr = ''
            if(this.linkName == '科室审核'){
                returnStr = this.form.fksldyj
            } else if(this.linkName == '办公室意见'){
                returnStr = this.form.fbgsyj
            } else if(this.linkName == '中心分管领导审核'){
                returnStr = this.form.ffgldyj
            } else if(this.linkName == '中心主要领导审核'){
                returnStr = this.form.fzxld
            }
            let data = {
                jobid: jobid,
                opinion: returnStr,
                shjid: ids,
                smgflag: '',
                smsContent: '',
            }
            returnUpperzdyFlowJob(data).then(res => {
                if(res.code == 200){
                    this.$message.success(res.message)
                    this.closeVisible()
                } else {
                    this.$message.error(res.message)
                }
            })
        },
    },
    watch: {
    formData(newval,oldVal){
      //console.log(newval)
      this.form = {...newval}
      if(this.linkName == '起草'){
        let nian = this.form.frq.substr(0,4)
        let yue = this.form.frq.substr(5,2)
        let ri = this.form.frq.substr(8,2)
        this.form.frq = nian + '-' + yue + '-' + ri
        //console.log(this.form.frq)
      }
      if(this.linkName == '流程监控'||this.linkName == '行政事务申请已办'||this.linkName == '我的已办'||this.linkName == '数据修订'){
        this.showFooter = true
      }

      let id = this.form.oaid
      flowJkPage({oaid:id}).then(res => {
        let arr1 = []
            arr1 = res.result.records
        var arr2 = new Array();
        for (let i = arr1.length - 1; i >= 0; i--) {
          arr2.push(arr1[i]);
        }
        // //console.log('arr2',arr2)
        this.lzList = []
        arr1.forEach(item => {
            item = {
                ...item,
                key: item.jobid
            }
            this.lzList.push(item)
            //console.log('IMG')
            this.imgList.forEach((items,a)=> {
                if(item.fdbrid){
                    if(items.fhjmc == item.fhjmc){
                    downMyQm({id:item.fdbrid}).then(resa => {
                        if(resa.code){
                        this.imgList[a].url = null
                        } else {
                        this.imgList[a].url = "data:image/png;base64," +
                        btoa( new Uint8Array(resa).reduce( (data, byte) => data + String.fromCharCode(byte), "" ))
                        }
                    })
                    }
                } else {}
            })
            //console.log('this.imgList',this.imgList)
        })
      })
      if(this.linkName == '数据修订'){
        this.getqueryAllYbJob()
        this.returnYj = ''
      }
      fjlist({foaid:this.form.id}).then(res => {
        this.filesListData = []
        this.filesListData = res.result.records
        //console.log(res)
      })
    },
  },

}
</script>
<style>
@import url('../../css/oaLess.css');
@import url('../../css/oaClass.css');
</style>
